package com.znf4.controller.user;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.znf4.entity.ApiCommonResultVo;
import com.znf4.user.info.entity.UserInfo;
import com.znf4.user.info.server.UserInfoServer;

/**
 * 用户信息 
 */
@RestController
@RequestMapping("/user/info")
public class UserInfoController {
	
	private static final Logger LOG = LoggerFactory.getLogger(UserInfoController.class);
	
	@Autowired
	private UserInfoServer userInfoServer ;
	
	
	
	/**
	 * 函数功能说明 ： 修改用户信息
	 *
	 * @参数： @return
	 * @return String
	 * @throws
	 */
	@RequestMapping(value = "/update", method = { RequestMethod.POST, RequestMethod.GET })
	public ApiCommonResultVo update(UserInfo userInfo , Model model) {
		
		try {
			userInfoServer.updateUserInfo(userInfo);
		    return new ApiCommonResultVo(0, "操作成功", userInfo ); 
		} catch (Exception e) {
			LOG.info("修改用户信息接口异常 ：" + e.getMessage());
			return new ApiCommonResultVo(-2, "系统异常", "");
		}
		
	}

	

	/**
	 * 函数功能说明 ： 获取用户信息
	 *
	 * @参数： @return
	 * @return String
	 * @throws
	 */
	@RequestMapping(value = "/queryOne", method = { RequestMethod.POST, RequestMethod.GET })
	public ApiCommonResultVo queryOne(UserInfo userInfo ) {
		
		try {
			userInfo = userInfoServer.queryOne(userInfo);
		    return new ApiCommonResultVo(0, "操作成功", userInfo ); 
		} catch (Exception e) {
			LOG.info("获取用户信息接口异常 ：" + e.getMessage());
			return new ApiCommonResultVo(-2, "系统异常", "");
		}
		
		
	}
	
	

}
